<?php
class LoginController extends Zend_Controller_Action
{
    public function init ()
    {
        /* Initialize action controller here */
    }
    public function indexAction ()
    {
        $request = $this->getRequest();
        $form = new Application_Form_Login();
        if ($this->getRequest()->isPost()) {
            if ($form->isValid($request->getPost())) {
                $name = $_POST['name'];
                $password = $_POST['password'];
                $mapper = new Application_Model_UserMapper();
                $users = $mapper->fetchByName('Name', $name);
                if (! empty($users[0]) &&
                 $users[0]->getPassword() == md5($password)) {
                    echo "log success";
                } else {
                    echo "log fail";
                }
                return $this->_helper->redirector('index');
            }
        }
        $this->view->form = $form;
    }
}

